<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <pre>
        <!-- 1.计算属性依赖data里面的数据进行缓存 -->
    </pre>
    <div id="app">
        <input type="text" v-model="age" />
        <div>{{remsg}}</div>
        <div>{{remsg}}</div>
        <div>{{ageHan()}}</div>
        <div>{{ageHan()}}</div>
    </div>
    <script src="../vue.js"></script>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                name: 'hello',
                age: '25',
            },
            methods: {
                ageHan: function() {
                    console.log('方法');
                    return this.age >= 18 ? '成年' : '未知';
                },
            },
            computed: {
                remsg: function() {
                    console.log('计算属性');
                    return this.name.split('').reverse().join('');
                },
            },
        });
    </script>
</body>

</html>